package com.IO流;

import java.io.UnsupportedEncodingException;
import java.util.Arrays;

public class 编码解码 {
    public static void main(String[] args) throws UnsupportedEncodingException {
        String s="中国";
        byte[] bys1=s.getBytes();
        byte[] bys2=s.getBytes("GBK");
        System.out.println("默认编码方式:"+Arrays.toString(bys1));
        System.out.println("GBK编码方式:"+Arrays.toString(bys2));
        System.out.println(" - - - - - - - - - - - - - - - - - -");
        System.out.println("默认的解码方式:默认编码");
        String s1=new String(bys1);
        System.out.println(s1);
        System.out.println("GBK解码方式:默认编码方式");
        String s2=new String(bys1,"GBK");
        System.out.println(s2);
        System.out.println("默认的解码方式:GBK编码方式");
        String s3=new String(bys2);
        System.out.println(s3);
        System.out.println("GBK解码方式:GBK编码方式");
        String s4=new String(bys2,"GBK");
        System.out.println(s4);


    }
}
